package com.bawei.module_main.ui.main

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.bawei.lib_common.base.BaseViewModel
import com.bawei.module_main.model.AppUpdateModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

/**
 * @author yaotianxue
 * @description
 * @date 2025/5/26
 */
@HiltViewModel
class MainViewModel @Inject constructor(private val repository: MainRepository):BaseViewModel() {

    private val appUpdateLiveData by lazy{
        MutableLiveData<AppUpdateModel>()
    }

    val appUpdateLiveData_:LiveData<AppUpdateModel> = appUpdateLiveData

    /**
     * 版本更新
     */
    fun checkUpdate(){
        execute(
            action = repository.checkUpdate(),
            onFinish = {
                appUpdateLiveData.value = it.data
            }
        )
    }
}